const api = require('../../../utils/interface.js')
const math = require('../../../utils/math.js')
const tools = require('../../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    details: {},
    src:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    this.getOrderDetails(options.orderNumber)
  },
  // 获取订单详细
  getOrderDetails(orderNumber) {
    api.getROrder({
      orderNumber
    }).then(res => {
      console.log(res.data.result)
      let data = res.data.result
      data.amount_ = math.divide(data.amount, 100)
      data.redPackedAmount_ = math.divide(data.redPackedAmount, 100)
      data.createTime_ = tools.formatTime(new Date(data.createTime))
      data.receiveAmount_ = data.receiveAmount ? math.divide(data.receiveAmount, 100) :0
      data.payType_ = ""
      switch (data.payType) {
        case '1':
          data.payType_ = '支付宝'
          this.data.src = '/static/zfb.png'
          break;
        case '2':
          data.payType_ = '微信'
          this.data.src = '/static/wechat.png'
          break;
        case '3':
          data.payType_ = '银联'
          this.data.src = '/static/yl.png'
          break;
        case '4':
          data.payType_ = '余额'
          this.data.src = '/static/ye.png'
          break;
        case '5':
          data.payType_ = '现金'
          this.data.src = '/static/xj.png'
          break;
        case '6':
          data.payType_ = '一网通'
          break;
      }
      data.service = data.serviceCardIds ? data.serviceCardIds.split(',').length:0
      
      this.setData({
        details: res.data.result,
        src:this.data.src
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})